#include <iostream>

class Animal
{
public:
    virtual void speak()
    {
        std::cout<<"动物叫声"<<std::endl;
    }

    // virtual ~Animal() //虚析构函数
    // {
    //     std::cout<<"父类析构\n";
    // }
};

class Dog : public Animal
{
public:
    void speak()
    {
        std::cout<<"汪汪汪"<<std::endl;

    }
    ~Dog()
    {
        std::cout<<"Dog析构\n";
    }
};

class Cat : public Animal
{
public:
    void speak()
    {
        std::cout<<"喵喵喵"<<std::endl;
    }

    ~Cat()
    {
        std::cout<<"Cat析构\n";
    }
};


void Show(Animal *a)
{
    a->speak();
}

int main()
{
    Animal *a = new Dog;
    Animal *b = new Cat;
    Show(a);
    Show(b);
    delete a;
    delete b;

    return 0;
}